package com.jinken.controller;

import com.jinken.common.R;
import com.jinken.pojo.User;
import com.jinken.service.IUserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {


    @DubboReference
    private IUserService userService;


    @RequestMapping("/user/list")
    public R list(){
        return userService.selectAll();
    }

    @RequestMapping("/user/getById")
    public R getById(@RequestParam("id") Integer id){
        return userService.selectById(id);
    }
    @RequestMapping("/user/add")
    public R add(@RequestBody User user){
        return userService.addUser(user);
    }

    @RequestMapping("/user/update")
    public R update(@RequestBody User user){
        return userService.updateUser(user);
    }

    @RequestMapping("/user/delete")
    public R delete(@RequestParam("id") Integer id){
        return userService.deleteByid(id);
    }
}
